<template>
	<view class="index-bg">
		<view class="stars">
			<view class="star"></view>
			<view class="star" style="top: 0rpx; left: -200rpx; animation-delay: 0s;"></view>
			<view class="star" style="top: 140rpx; left: -146rpx; animation-delay: 0.5s;"></view>
			<view class="star" style="top: 120rpx; left: 0rpx; animation-delay: 1s;"></view>
			<view class="star" style="top: 260rpx; left: 165rpx; animation-delay: 1s;"></view>
			<view class="star" style="top: 170rpx; left: 400rpx; animation-delay: 2s;"></view>
			<view class="star" style="top: 170rpx; left: 200rpx; animation-delay: 3s;"></view>
			<view class="star" style="top: 200rpx; left: 500rpx; animation-delay: 1s;"></view>
			<view class="star" style="top: 200rpx; left: 165rpx; animation-delay: 2.5s;"></view>
		</view>
		<view class="ZS-header">
			<view class="ZS-title">my life</view>
		</view>
		<view class="ZS-contant-box">
			<view class="ZS-contant">
				<div class="ZS-Title-box">
					<view class="title-time animate__animated animate__bounceInLeft" style="font-size: 60rpx;font-weight: 700;">《废物的一生》</view>
				</div>
				<view class="contant-btn-box" style="border-radius: 8px;">
					<view class="title-time animate__animated animate__bounceInRight" style="margin-top: 40rpx;font-size: 30rpx;font-weight: 700;">距离{{ newDayLIst[0].title }} 还有 {{ newDayLIst[0].newTime }} 天</view>
					<view class="title-time animate__animated animate__bounceInRight" style="margin-top: 40rpx;font-size: 30rpx;font-weight: 700;">距离{{ newDayLIst[1].title }} 还有 {{ newDayLIst[1].newTime }} 天</view>
					<view class="title-time animate__animated animate__bounceInRight" style="margin-top: 40rpx;font-size: 30rpx;font-weight: 700;">距离{{ newDayLIst[2].title }} 还有 {{ newDayLIst[2].newTime }} 天</view>
					<view class="title-time animate__animated animate__bounceInRight" style="margin-top: 40rpx;font-size: 30rpx;font-weight: 700;">距离{{ newDayLIst[3].title }} 还有 {{ newDayLIst[3].newTime }} 天</view>
				</view>
				<view class="contat-Time">
					<view class="title-time animate__animated animate__bounceInLeft" style="margin-top: 80rpx;font-size: 40rpx;font-weight: 700;">我存活 - 至今</view>
					<view class="cotat-title-tiem animate__animated animate__bounceInUp">
						<view class="cotat-title-tiem-box animate__animated animate__bounceInUp">
							<view style="font-size: 40rpx;font-weight: 700;">{{ newDay }}</view>
							<view class="cotat-title-tiem-box-date" style="">天</view>
						</view>
						<view class="cotat-title-tiem-box animate__animated animate__bounceInDown">
							<view style="font-size: 40rpx;font-weight: 700;">{{ newHour }}</view>
							<view class="cotat-title-tiem-box-date" style="">小时</view>
						</view>
						<view class="cotat-title-tiem-box animate__animated animate__bounceInUp">
							<view style="font-size: 40rpx;font-weight: 700;">{{ newMin }}</view>
							<view class="cotat-title-tiem-box-date" style="">分</view>
						</view>
						<view class="cotat-title-tiem-box animate__animated animate__bounceInDown">
							<view style="font-size: 40rpx;font-weight: 700;">{{ newAfterMin }}</view>
							<view class="cotat-title-tiem-box-date" style="">秒</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="ZS-footer">
		</view>
	</view>
</template>

<script>
import { dayList } from '../../config/commemorationDay.js'
	export default {
		data() {
			return {
				newDay: '00000',
				newHour: '00',
				newMin: '00',
				newAfterMin: '00',
				newTimeNum: '2000-02-15', // 告白纪念日 2000-02-15 09:00:00
				newDayLIst: [],
			}
		},
		onLoad() {
			this.newTime()
			this.commemorationDay()
		},
		methods: {
			jumpRouter(path) {
				uni.navigateTo({
				    url: path
				});
			},
			commemorationDay () {
				const s2 = new Date().getTime()
				dayList.forEach(item => {
					let d1 = 0
					if (item.Num) {
						d1 = new Date(item.time).getTime() + item.Num * 86400000
					} else {
						d1 = new Date(item.time).getTime()
					}
					if (s2 < d1 && this.newDayLIst.length <= 4) {
						item['newTime'] = parseInt((d1- s2) / (24*60*60*1000)) + 1
						this.newDayLIst.push(item)
					}
				})
			},
			newTime() {
				const s2 = new Date().getTime()
				const s1 = new Date(this.newTimeNum).getTime()
				const total = (s2 - s1)/1000;
				const day = parseInt(total / (24*60*60));//计算整数天数
				const afterDay = total - day*24*60*60;//取得算出天数后剩余的秒数
				const hour = parseInt(afterDay/(60*60));//计算整数小时数
				const afterHour = total - day*24*60*60 - hour*60*60;//取得算出小时数后剩余的秒数
				const min = parseInt(afterHour/60);//计算整数分
				const afterMin = parseInt(total - day*24*60*60 - hour*60*60 - min*60);//取得算出分后剩余的秒数
				// console.log(day + 'tian', hour +'时', min + 'fen', afterMin + 'miao');
				this.newDay = day
				this.newHour = hour
				this.newMin = min
				this.newAfterMin = afterMin
				setTimeout(() => {
					this.newTime()
				}, 1000)
			}
		}
	}
</script>

<style>
.cotat-title-tiem-box-date {
	font-size: 30rpx;
	height: 46rpx;
	line-height: 46rpx;
	margin-top: 6rpx;
	font-weight: 700;
	width: 90%;
	text-align: center;
	background-color: rgba(255, 255, 255, 0.205);
}
.cotat-title-tiem-box {
	width: 180rpx;
	height: 140rpx;
	border: 1px dashed #fff;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}
.cotat-title-tiem {
	display: flex;
	justify-content: space-between;
	width: 90%;
	margin-top: 40rpx;
	height: 200rpx;
	/* border: 1px solid #fff; */
}
.ZS-Title-box {
	width: 100%;
	padding-top: 100rpx;
	text-align: center;
}
.contant-btn-box {
	width: 80%;
	height: 60px;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	margin: 0 auto;
	margin-top: 60px;
}
.contat-Time {
	color: #fff;
	position: absolute;
	bottom: 0;
	width: 100%;
	height: 340rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	/* justify-content: center; */
	/* margin: 0 auto; */
	/* margin-top: 20%; */
	/* border-radius: 50rpx; */
	/* box-shadow: 4px 8px 10px 1px rgba(0, 0, 0, 0.4); */
}
.title-time {
	color: #fff;
	/* text-shadow: 5px 5px 5px #FF0000 */
	text-shadow: 2px 4px 10px rgba(0, 0, 0, 0.3);
}
.ZS-title {
	margin-top: 160rpx;
	color: #fff;
	font-size: 40rpx;
	font-weight: 700;
}
.ZS-footer {
	position: absolute;
	bottom: 0;
	width: 100%;
	height: 300rpx;
	display: flex;
	justify-content: space-around;
}
.ZS-header {
	width: 100%;
	height: 100rpx;
	display: flex;
	justify-content: center;
	align-items: center;
}
.ZS-contant {
	position: relative;
	width: 100%;
	height: 100%;
	/* border: 1px solid #b0e0ff; */
	border-radius: 150rpx;
}
.ZS-contant-box {
	width: 100%;
	padding-bottom: 300rpx;
	flex: 1;
}
.ZS-box {
	width: 100vw;
	display: flex;
	flex-direction: column;
	align-items: center;
	height: 100vh;
	box-sizing: border-box;
}
.content_round {
	width: 500rpx;
	height: 150rpx;
	border-radius: 150rpx;
	text-align: center;
	line-height: 150rpx;
	background-color: #b0e0ff;
	box-shadow: 0px 0px 20px 2px #b0e0ff;
	color: #8170c0;
	font-weight: 700;
	margin-top: 160rpx;
}
@-webkit-keyframes star-opacity {
		0% {
				opacity: 0
		}

		40% {
				opacity: 1
		}

		60% {
				opacity: 1
		}

		100% {
				opacity: 0
		}
}

@keyframes star-opacity {
		0% {
				opacity: 0
		}

		40% {
				opacity: 1
		}

		60% {
				opacity: 1
		}

		100% {
				opacity: 0
		}
}

@-webkit-keyframes star-pos {
		0% {
				transform: scale(0) rotate(0) translate3d(0, 0, 0);
				-webkit-transform: scale(0) rotate(0) translate3d(0, 0, 0);
				-moz-transform: scale(0) rotate(0) translate3d(0, 0, 0)
		}

		100% {
				transform: scale(1) rotate(0) translate3d(-450px, 450px, 0);
				-webkit-transform: scale(1) rotate(0) translate3d(-450px, 450px, 0);
				-moz-transform: scale(1) rotate(0) translate3d(-450px, 450px, 0)
		}
}

@keyframes star-pos {
		0% {
				transform: scale(0) rotate(0) translate3d(0, 0, 0);
				-webkit-transform: scale(0) rotate(0) translate3d(0, 0, 0);
				-moz-transform: scale(0) rotate(0) translate3d(0, 0, 0)
		}

		100% {
				transform: scale(1) rotate(0) translate3d(-450px, 450px, 0);
				-webkit-transform: scale(1) rotate(0) translate3d(-450px, 450px, 0);
				-moz-transform: scale(1) rotate(0) translate3d(-450px, 450px, 0)
		}
}

body {
		padding: 0;
		margin: 0;
}

.index-bg {
	width: 100vw;
	display: flex;
	flex-direction: column;
	align-items: center;
	height: 100vh;
	box-sizing: border-box;
	background: linear-gradient(-225deg, #473B7B 0%, #3584A7 51%, #30D2BE 100%);
}

.index-bg .stars {
		height: 0
}

.index-bg .star {
		display: block;
		width: 5px;
		height: 5px;
		border-radius: 50%;
		background: #fff;
		top: 100px;
		left: 400px;
		position: relative;
		-webkit-transform-origin: 100% 0;
		transform-origin: 100% 0;
		-webkit-animation: star-opacity 4s infinite ease-in, star-pos 4s infinite ease-in;
		animation: star-opacity 4s infinite ease-in, star-pos 4s infinite ease-in;
		-webkit-box-shadow: 0 0 5px 5px rgba(255, 255, 255, .3);
		box-shadow: 0 0 5px 5px rgba(255, 255, 255, .3);
		opacity: 0;
		z-index: 2
}

.index-bg .star:after {
		content: '';
		display: block;
		top: 0;
		left: 4px;
		border: 0 solid #fff;
		border-width: 0 90px 2px;
		border-color: transparent transparent transparent rgba(255, 255, 255, .3);
		-webkit-transform: rotate(-45deg) translate3d(1px, 3px, 0);
		transform: rotate(-45deg) translate3d(1px, 3px, 0);
		-webkit-box-shadow: 0 0 1px 0 rgba(255, 255, 255, .1);
		box-shadow: 0 0 1px 0 rgba(255, 255, 255, .1);
		-webkit-transform-origin: 0% 100%;
		transform-origin: 0% 100%
}
</style>
